Handle missing cases in CollectAnnotatedSymbolsPsiVisitor#2862
Handle missing cases in CollectAnnotatedSymbolsPsiVisitor#2862
CollectAnnotatedSymbolsPsiVisitor#2862Conversation
fb528fe to
a2887fa
Compare
c43931d to
ee70d77
Compare
| return | ||
| } | ||
|
|
||
| null -> |
There was a problem hiding this comment.
Why not crash for null and PsiType?
Do you have examples what code leads to these cases?
There was a problem hiding this comment.
In particular, I'm curious if you've actually hit issues with this or if this is just to preemptively handle these cases in case they happen. Note that I don't think we technically need to handle every case exhaustively since our visitor itself skips a lot cases we don't care about. Especially, after #2863 where you improve the skip logic, I would be curious if we need to handle null and PsiType. If we don't have explicit failure cases for these then I would lean towards just crashing until someone reports a case and we can investigate the specific issue.
There was a problem hiding this comment.
This case was observed when returning an annotation as a default value for another annotation, e.g.,
public @interface JavaAnnotationWithDefaults {
OtherAnnotation otherAnnotationVal() default @OtherAnnotation("def");
}See annotationValue_java.kt. In this example, the default value for otherAnnotationVal is @OtherAnnotation("def")
...pi/src/main/kotlin/com/google/devtools/ksp/impl/visitor/CollectAnnotatedSymbolsPsiVisitor.kt
Show resolved
Hide resolved
ee70d77 to
d22a2a4
Compare
d22a2a4 to
5fa573b
Compare
ec8b8dd to
3035d09
Compare
3035d09 to
701d49f
Compare
I studied the structure of
PsiAnnotationa bit further and found what is hopefully an exhaustive solution.Related to #2816